package date

import t "time"

const (
	FmtFull      = "2006-01-02 15:04:05"
	FmtDay       = "2006-01-02"
	FmtTime      = "15:04:05"
	FmtFullShort = "20060102150405"
	FmtDayShort  = "20060102"
	FmtTimeShort = "150405"
)

func CurrTimestampS() int64 {
	return t.Now().Unix()
}

func CurrTimestampMS() int64 {
	return t.Now().UnixMilli()
}

// 返回设备所在时区的时间,format可从date.FmtFull等等众多预设中取
func TimestampSFmt(timestampS int64, format string) string {
	return t.Unix(timestampS, 0).Format(format)
}

// 返回设备所在时区的时间,format可从date.FmtFull等等众多预设中取
func TimestampMSFmt(timestampMS int64, format string) string {
	return t.UnixMilli(timestampMS).Format(format)
}

// 返回设备所在时区的时间,format可从date.FmtFull等等众多预设中取
func TimestampSFmtByTimezone(timestampS int64, format, timezone string) string {
	loc, _ := t.LoadLocation(timezone)
	return t.Unix(timestampS, 0).In(loc).Format(format)
}

// 返回设备所在时区的时间,format可从date.FmtFull等等众多预设中取
func TimestampMSFmtByTimezone(timestampMS int64, format, timezone string) string {
	loc, _ := t.LoadLocation(timezone)
	return t.UnixMilli(timestampMS).In(loc).Format(format)
}

func Utc2Beijing(time t.Time) t.Time {
	location, _ := t.LoadLocation("Asia/Shanghai")
	return time.In(location)
}
